﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business;

namespace WebApplication1.masterpage
{
    public partial class Main : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            UserManagement user = new UserManagement();
            bool isUser = user.Authenticate(txtUser.Text, Security.EncodePassword(txtPassword.Text));
            //bool isUser = user.Authenticate(txtUser.Text, txtPassword.Text);
            if (isUser)
            {
                Business.User userobj = user.GetUser(txtUser.Text);
                //save into session object
                Session["User"] = userobj;
                Response.Redirect("~/Caterer.aspx");

            }
            else
            {
                divMessage.Visible = true;
                lblMessage.Text = "Invalid email or password!";

            }
        }
    }
}